//File  :mysql.go

package database

import (
	"fmt"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

var Db *gorm.DB
var err error

func init() {
	Db, err = gorm.Open("mysql", "root:lxy4438.@/cathomestay?charset=utf8&parseTime=True&loc=Local")

	//自动同步表结构
	//Db.AutoMigrate(&UserLogin{}, &UserInfo{})

	if err != nil {
		fmt.Printf("mysql connect error %v", err)
	}
	if Db != nil {
		fmt.Printf("database error %v", Db.Error)
	}
}
